# Filters added to this controller will be run for all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

require 'login_engine'

require 'gettext/rails'


class ApplicationController < ActionController::Base

  include LoginEngine
  include UserEngine

  helper :user
  model :user

  before_filter :authorize_action, :except => [ :login, :signup ]
  before_filter :set_charset, :cookie_lang

  init_gettext "i18n_gettext"

  def cookie_lang
    cookies["lang"] = 'zh'
  end

  def set_charset
    if request.xhr?
      @headers["Content-Type"] = "text/javascript; charset=utf-8"
    else
      @headers["Content-Type"] = "text/html; charset=utf-8"
    end
  end

end

